// pages/bind_and_update/bind_and_update.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (t) {
    getApp().page.onLoad(this, t);
    console.log(getApp().getUser().id)
    console.log('tttt', t)
    wx.setStorageSync('recommender_id', t.scene)
  },
  onShow: function (e) {
    var o = this
    console.log('onshow', o.data)

    setTimeout(
      function () {
        var recommender_id = wx.getStorageSync('recommender_id')
        o.bind_and_update(getApp().getUser().id, recommender_id)
      },
      100)
  },
  bind_and_update: function (user_id, parent_id) {
    var a = this
    getApp().request({
      url: getApp().api.share.bind_and_update,
      data: {
        user_id: user_id,
        parent_id: parent_id
      },
      success: function (t) {
        console.log(t)
        if (t.code == 0) {

        } else {
          wx.showToast({
            title: t.msg,
            icon: 'none',
            duration: 2000
          })
        }
      },
      complete: function (t) {
        getApp().core.hideLoading();
      }
    });
  },
  integral:function(e){
    wx.reLaunch({
      url: '/pages/integral-mall/index/index',
    })
  }
})